package wili.logic;

import java.util.Map;
import java.util.Set;
import java.util.TreeMap;

import wili.c.Ca;

/**
 * @author weila 2022年10月6日
 */
class AndOrExp_test {
	static Map<String, Set<String>> varNameToValuesMap = new TreeMap<>();

	static void isEquivalentLogicExp_test(int use) {
		if (use < 0)
			return;
		if (Boolean.FALSE) {
			AndOrExp.isEquivalentLogicExp(null, null);
		}
		Object[][] test = {
				{ true, "${view>/$EditMode/editMode}", "!${view>/$EditMode/addMode} && !${view>/$EditMode/viewMode}" },
				{ true, "${DocStatus} === 'C' || ${DocStatus} === 'A'",
						"${DocStatus} !== 'N' && ${DocStatus} !== 'O'" }, //
				{ false, "${DocStatus} !== 'C'", "${DocStatus} === 'A' || ${DocStatus} !== 'O'" }, //
				// { false, "[undefined, null,'-1'].includes(${DocEntry})", "[undefined,
				// null].includes(${DocEntry})"}, //
		};
		for (int i = 0; i < test.length; i++) {
			Object[] tt = test[i];
			AndOrExp.EquivalentRet ret = AndOrExp.isEquivalentLogicExp(tt[1].toString(), tt[2].toString());
			if (ret == null) {
				Ca.asert(tt[0] == null, ret);
			} else if (ret.map.isEmpty()) {
				Ca.asert(tt[0].equals(true), ret);
			} else {
				Ca.log(i + "--------");
				Ca.log("formula1:" + tt[1]);
				Ca.log("formula2:" + tt[2]);
				Ca.log("eg. not eq if has values:\n\t" + ret);
				Ca.asert(tt[0].equals(false), "");
			}
		}
		Ca.pause();
	}

	public static void test(int use) {
		if (use < 0)
			return;
		if ("".isEmpty())
			return;
		isEquivalentLogicExp_test(1);
	}

	public static void main(String[] args) {
		test(1);
	}
}